if(@ARGV == 0)
{
        die "no arguments\n";
}
$tpedfile = $ARGV[0];
chomp($tpedfile);
open TPED,"$tpedfile" or die "no file exists $tpedfile\n";

for($i=1;$i<@ARGV-1;$i++)
{
        $file = $ARGV[$i];
        chomp($file);
	open BUFF,"$file" or die "no file exists $file\n";
	while(<BUFF>)
	{
		chomp($_);
		@array = split(/\t/,$_);
		if(exists($hash{$array[0]}))
		{
			if($array[1] > 1)
			{
				$hash{$array[0]} = $array[1];
			}
		}
		else
		{
			$hash{$array[0]} = $array[1];
		}
	}	
	close(BUFF);	
}
$file = $ARGV[@ARGV-1];
chomp($file);
open WRBUFF,">$file";
while(<TPED>)
{
	chomp($_);
	@array = split(/ /,$_);
        if(exists($hash{$array[1]}))
	{
		print WRBUFF $array[1]."\t".$hash{$array[1]}."\n";
	}	
	else
	{
		die "no forward information for snp $array[1]\n";
	}
}
